# -*- coding = utf-8 -*-
from flask import Flask,jsonify,render_template,request
from panduan import panduan
from gaode import geocode,weatherinfo
li_key="31e2e9ede61f2f81638ca15063de2984"

app = Flask(__name__)

@app.route("/",methods = ["GET"])
def hello() ->str:
	return "welcome to python-web"


@app.route("/entry",methods = ["GET"])
def hello_entry() ->"html":
	return render_template("Login.html")

@app.route("/search",methods = ["POST"])
def hello_login():
	zhanghao = request.form["zhanghao"]
	mima = request.form["mima"]
	a = panduan(zhanghao,mima)
	maincity = request.form["city"]
	tianqi = weatherinfo(maincity)
	if a == "true":
		province1 = tianqi["lives"][0]['province']
		city1 = tianqi["lives"][0]['city']
		adcode1 = tianqi["lives"][0]['adcode']
		weather1 = tianqi["lives"][0]['weather']
		temperature1 = tianqi["lives"][0]['temperature']
		winddirection1 = tianqi["lives"][0]['winddirection']
		windpower1 = tianqi["lives"][0]['windpower']
		humidity1 = tianqi["lives"][0]['humidity']
		reporttime1 = tianqi["lives"][0]['reporttime']
		return render_template(
			"loginjianying.html",
			the_geocode = tianqi,
			province = province1,
			city = city1,
			adcode = adcode1,
			weather = weather1,
			temperature = temperature1,
			winddirection = winddirection1,
			windpower = windpower1,
			humidity = humidity1,
			reporttime = reporttime1
			)
	else:
		return render_template("loginfail.html",loginfail = "登录失败")




if __name__ == '__main__':
	app.run(debug=True)